//
//  dTextFieldViewController.m
//  Surveyer
//
//  Created by Qikun Guo on 13-7-30.
//  Copyright (c) 2013年 Tim. All rights reserved.
//

#import "dTextFieldViewController.h"

@interface dTextFieldViewController ()

@end

@implementation dTextFieldViewController
@synthesize titleLabel, theTextField, subTitleLabel, currentItem, currentResult;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    titleLabel.text = currentItem.title;
    subTitleLabel.text = currentItem.value1;
    theTextField.text = currentResult.text;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    self.editCount ++;
    if (!currentResult) {
        currentResult = [[SurveyerStore defaultStore] createResultWithSurveyItem:currentItem];
    }
    currentResult.text = theTextField.text;
    [self.delegate currentItemCompleted:self];
    return YES;
}
@end
